package com.bw.dao.impl;

import com.bw.dao.UserRoleDao;
import com.bw.pojo.Role;
import com.bw.pojo.UserRole;
import com.bw.pojo.vo.GetUserDetailsVo;

import java.util.List;
import java.util.Map;

public class UserRoleDaoImpl extends BaseDao implements UserRoleDao {
    /**
     * 查询所有角色列表信息
     * @return
     */
    @Override
    public List<Role> getRoleAllList() {
        String sql = "select * from r_role";
        return baseQueryList(Role.class, sql);
    }

    /**
     * 根据用户id 查询 中间表数据
     * 查询当前用户 已经拥有的角色
     * @param uid
     * @return
     */
    @Override
    public List<UserRole> findUserRoleByUid(String uid) {
        String sql = "select * from t_user_role where uid = ? ";
        return baseQueryList(UserRole.class, sql,uid);
    }

    @Override
    public void delUserRole(Integer uid) {
        String sql = "delete from t_user_role where uid = ? ";
        baseUpdate(sql,uid);
    }

    @Override
    public void addUserRole(Integer uid, List<Integer> rids) {
        String sql = "insert into t_user_role(uid,rid) values (?,?)";
        baseUpdate(sql, uid,rids);
    }

    @Override
    public List<Map<String, Object>> getUserRoleByUserId(Integer uid) {
        return null;
    }

}
